package com.ruoyi.model.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.model.domain.ModelColumnInfo;
import com.ruoyi.model.service.IModelColumnInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 模型详细信息Controller
 * 
 * @author genghz
 * @date 2021-10-20
 */
@RestController
@RequestMapping("/model/column")
public class ModelColumnInfoController extends BaseController
{
    @Autowired
    private IModelColumnInfoService modelColumnInfoService;

    /**
     * 查询模型详细信息列表
     */
    @PreAuthorize("@ss.hasPermi('model:column:list')")
    @GetMapping("/list")
    public TableDataInfo list(ModelColumnInfo modelColumnInfo)
    {
        startPage();
        List<ModelColumnInfo> list = modelColumnInfoService.selectModelColumnInfoList(modelColumnInfo);
        return getDataTable(list);
    }

    /**
     * 导出模型详细信息列表
     */
    @PreAuthorize("@ss.hasPermi('model:column:export')")
    @Log(title = "模型详细信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ModelColumnInfo modelColumnInfo)
    {
        List<ModelColumnInfo> list = modelColumnInfoService.selectModelColumnInfoList(modelColumnInfo);
        ExcelUtil<ModelColumnInfo> util = new ExcelUtil<ModelColumnInfo>(ModelColumnInfo.class);
        return util.exportExcel(list, "模型详细信息数据");
    }

    /**
     * 获取模型详细信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:column:query')")
    @GetMapping(value = "/{columnId}")
    public AjaxResult getInfo(@PathVariable("columnId") Long columnId)
    {
        return AjaxResult.success(modelColumnInfoService.selectModelColumnInfoByColumnId(columnId));
    }

    /**
     * 新增模型详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:column:add')")
    @Log(title = "模型详细信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ModelColumnInfo modelColumnInfo)
    {
        return toAjax(modelColumnInfoService.insertModelColumnInfo(modelColumnInfo));
    }

    /**
     * 修改模型详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:column:edit')")
    @Log(title = "模型详细信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ModelColumnInfo modelColumnInfo)
    {
        return toAjax(modelColumnInfoService.updateModelColumnInfo(modelColumnInfo));
    }

    /**
     * 删除模型详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:column:remove')")
    @Log(title = "模型详细信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{columnIds}")
    public AjaxResult remove(@PathVariable Long[] columnIds)
    {
        return toAjax(modelColumnInfoService.deleteModelColumnInfoByColumnIds(columnIds));
    }
}
